 package com.itic.mall.mobile.product;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.itic.appbase.framework.common.constants.DBConst;
import com.itic.appbase.framework.utils.NumberStringHelper;
import com.itic.appbase.framework.utils.StringHelper;
import com.itic.mall.mobile.base.BaseMobileInterface;
import com.itic.mall.system.banner.persistence.model.Banner;
import com.itic.mall.system.banner.persistence.model.BannerExample;
import com.itic.mall.system.banner.service.BannerService;
import com.itic.mall.system.category.persistence.model.Category;
import com.itic.mall.system.category.persistence.model.CategoryExample;
import com.itic.mall.system.category.service.CategoryService;
import com.itic.mall.system.marketuser.persistence.model.MarketUser;
import com.itic.mall.system.product.persistence.model.Product;
import com.itic.mall.system.product.persistence.model.ProductExample;
import com.itic.mall.system.product.persistence.model.ProductExample.Criteria;
import com.itic.mall.system.product.service.ProductService;
import com.itic.mall.system.productfeedback.persistence.model.ProductFeedback;
import com.itic.mall.system.productfeedback.persistence.model.ProductFeedbackExample;
import com.itic.mall.system.productfeedback.service.ProductFeedbackService;
import com.itic.mall.system.productproperty.persistence.model.ProductProperty;
import com.itic.mall.system.productproperty.service.ProductPropertyService;
import com.itic.mall.system.productpropertyvalue.persistence.model.ProductPropertyValue;
import com.itic.mall.system.productpropertyvalue.service.ProductPropertyValueService;
import com.itic.mall.system.productsku.persistence.model.ProductSku;
import com.itic.mall.system.productsku.persistence.model.ProductSkuExample;
import com.itic.mall.system.productsku.service.ProductSkuService;
import com.itic.mall.system.user.persistence.model.MallUser;


/**
 * 友惠家商城中心接口类
 * @author 许小宝
 * 2017年07月25日  14时11分
 */
@Controller
@RequestMapping(value="/mobile/product")
public class MallProductInterface
     extends BaseMobileInterface {
   @Autowired
   private ProductService productService;
   @Autowired
   private ProductSkuService productSkuService;
   @Autowired
   private ProductPropertyService productPropertyService;
   @Autowired
   private ProductPropertyValueService productPropertyValueService;
   @Autowired
   private CategoryService categoryService;
   @Autowired
   private ProductFeedbackService productFeedbackService;
   @Autowired
   private BannerService bannerService;
   
   /**
    * APP折扣商城中心
    * @param categoryId 类别ID
    * @param orderType 排序类型
    * @param minMaxPrice 最小到最大的价格区间，中间用-号相隔
    * @param minMaxPrice 最小到最大的销量区间     中间用-号相隔
    * @return
    */
   @RequestMapping(value="/all")
   @ResponseBody
   public List<Product> all(HttpServletRequest request,HttpServletResponse response ){
	   	ProductExample example2 = new ProductExample();
		List<Product> list = productService.list(example2);
		isCrrossDomain(response);
	    return list;
   }
   
   /**
    * APP折扣商城中心
    * @param categoryId 类别ID
    * @param orderType 排序类型
    * @param minMaxPrice 最小到最大的价格区间，中间用-号相隔
    * @param minMaxPrice 最小到最大的销量区间     中间用-号相隔
    * @return
    */
   @RequestMapping(value="/update")
   @ResponseBody
   public Map<String,Object> update(HttpServletRequest request,HttpServletResponse response ){
   	Map<String, Object> resultMap = new HashMap<String,Object>();
   	String result = FAIL;
   	String errorCode = PARAM_ERROR_CODE;
   	String errorMsg = PARAM_ERROR_MSG;
   	try{
   		
   		ProductSkuExample example2 = new ProductSkuExample();
		example2.createCriteria().andIsEffectiveEqualTo(DBConst.TRUE).andIsMainEqualTo(DBConst.TRUE);
		List<ProductSku> list = productSkuService.list(example2);
		if( list.size()>0 ){
			for( ProductSku temp: list ){
				Product product = productService.get(temp.getProductId());
            	if( null != product ){
            		product.setProductOrginPrice(temp.getProductOrginPrice());
                    String productPrice = NumberStringHelper.subtractString(temp.getProductOrginPrice(), product.getProductHongbao());
                    product.setProductPrice(productPrice);
                    productService.edit(product);
            	}
			}
		}
		result = SUCCESS;
		errorCode = SUCCESS_ERROR_CODE;
       	errorMsg = SUCCESS_ERROR_MSG;  	
       	
   	}catch(Exception e){
   		errorCode = SERVER_ERROR_CODE;
       	errorMsg = SERVER_ERROR_MSG;
       	//log(e);
       	logException("MallProductInterface", "index", e.toString(),"折扣商城中心商品列表",e);
   		
   	}
   	resultMap.put(RESULT, result);
   	resultMap.put(ERROR_CODE, errorCode);
   	resultMap.put(ERROR_MSG, errorMsg);
   	isCrrossDomain(response);
   	return resultMap;
   }
   
   
    /**
     * APP折扣商城中心
     * @param categoryId 类别ID
     * @param orderType 排序类型
     * @param minMaxPrice 最小到最大的价格区间，中间用-号相隔
     * @param minMaxPrice 最小到最大的销量区间     中间用-号相隔
     * @return
     */
    @RequestMapping(value="/index")
    @ResponseBody
    public Map<String,Object> index(HttpServletRequest request,HttpServletResponse response, String name,String categoryId,String orderType,String minMaxPrice,String minMaxSales, String isServenBack, String percentFeedback ){
    	Map<String, Object> resultMap = new HashMap<String,Object>();
    	String result = FAIL;
    	String errorCode = PARAM_ERROR_CODE;
    	String errorMsg = PARAM_ERROR_MSG;
    	try{
    		Map<String, Object> dataMap = new HashMap<String,Object>();
    		
    		//根据条件查找相应 的商品信息 
    		ProductExample example = new ProductExample();
    		//example.setOrderByClause("CREATE_TIME DESC");
    		// 封装分页参数
            example = this.handlePageQueryDefault(request, example);
    		
    		Criteria criteria = example.createCriteria();
    		criteria.andIsEffectiveEqualTo(DBConst.TRUE);
    		
    		if( StringHelper.isNotBlank(categoryId) && !"0".equals(categoryId) ){
    			criteria.andCategoryIdEqualTo(categoryId);
    		}
    		
    		if( StringHelper.isNotBlank(orderType) ){
    			if( "priceDesc".equals(orderType) ){
    				example.setOrderByClause("PRODUCT_PRICE DESC");
    			}
    			if( "priceAsc".equals(orderType) ){
    				example.setOrderByClause("PRODUCT_PRICE ASC");
    			}
    			if( "salesDesc".equals(orderType) ){
    				example.setOrderByClause("TOTAL_SALES DESC");
    			}
    			if( "commissionAsc".equals(orderType) ){
    				example.setOrderByClause("MARKET_PROFIT DESC");
    			}
    			if( "commissionDesc".equals(orderType) ){
    				example.setOrderByClause("MARKET_PROFIT ASC");
    			}
    		}else{
    			//默认使用商品的创建时间倒序
    			example.setOrderByClause("UPDATE_TIME DESC");
    			example.setOrderByClause("REORDER ASC");
    		}
    		
    		if( StringHelper.isNotBlank(percentFeedback) ){
    			example.setOrderByClause("PERCENT_FEEDBACK DESC");
    		}
    		
    		//根据商品的名字模糊查询
    		if(StringHelper.isNotBlank(name)){
    			criteria.andNameLike("%"+name+"%");
    		}
    		
        	//过滤价格区间
        	if( StringHelper.isNotBlank(minMaxPrice) ){
        		String[] split = minMaxPrice.split("-");
        		if(split.length==2){
        			String minPrice = split[0];
            		String maxPrice = split[1];
            		if( StringHelper.isNotBlank(minPrice) ){
            			criteria.andProductOrginPriceGreaterThanOrEqualTo(Double.parseDouble(minPrice));
            		}
            		if( StringHelper.isNotBlank(maxPrice) ){
            			criteria.andProductOrginPriceLessThanOrEqualTo(Double.parseDouble(maxPrice));
            		}
        		}
        	}
        	
        	//过滤是否退换货
        	if( StringHelper.isNotBlank( isServenBack) && DBConst.TRUE.equals(isServenBack) ){
        		criteria.andIsServenBackEqualTo(DBConst.TRUE);
        	}
        	
        	//过滤销量区间
        	if( StringHelper.isNotBlank(minMaxSales) ){
        		String[] split = minMaxSales.split("-");
        		if( split.length == 2 ){
        			String minSale = split[0];
            		String maxSale = split[1];
            		if( StringHelper.isNotBlank(minSale) ){
            			criteria.andTotalSalesGreaterThanOrEqualTo(Integer.parseInt(minSale));
            		}
            		if( StringHelper.isNotBlank(maxSale) ){
            			criteria.andTotalSalesLessThanOrEqualTo(Integer.parseInt(maxSale));
            		}
            		
        		}
        		
        	}
        	int count = productService.count(example);
        	List<Product> products = productService.list(example);
        	dataMap.put("products", products);
        	dataMap.put("productCount", count + "");
         
        	//查找相应的分类信息
        	CategoryExample categoryExample = new CategoryExample();
        	categoryExample.createCriteria().andIsEffectiveEqualTo(DBConst.TRUE);
        	List<Category> categorys = categoryService.list(categoryExample);
        	dataMap.put("categroys", categorys);
        	
        	//查找banners信息
        	dataMap.put("banners", getBanners());
        	
        	//查找baokuan
        	dataMap.put("baokuans", getBaokuans());
        	
        	resultMap.put(DATA, dataMap);
			result = SUCCESS;
			errorCode = SUCCESS_ERROR_CODE;
        	errorMsg = SUCCESS_ERROR_MSG;  	
        	
    	}catch(Exception e){
    		errorCode = SERVER_ERROR_CODE;
        	errorMsg = SERVER_ERROR_MSG;
        	//log(e);
        	logException("MallProductInterface", "index", e.toString(),"折扣商城中心商品列表",e);
    		
    	}
    	resultMap.put(RESULT, result);
    	resultMap.put(ERROR_CODE, errorCode);
    	resultMap.put(ERROR_MSG, errorMsg);
    	isCrrossDomain(response);
    	return resultMap;
    }
    
    
    /**
     * APP折扣商城中心
     * @param categoryId 类别ID
     * @param orderType 排序类型
     * @param minMaxPrice 最小到最大的价格区间，中间用-号相隔
     * @param minMaxPrice 最小到最大的销量区间     中间用-号相隔
     * @return
     */
    @RequestMapping(value="/list")
    @ResponseBody
    public Map<String,Object> list(HttpServletRequest request,HttpServletResponse response, String name,String categoryId,String orderType,String minMaxPrice,String minMaxSales, String isServenBack, String percentFeedback ){
    	Map<String, Object> resultMap = new HashMap<String,Object>();
    	String result = FAIL;
    	String errorCode = PARAM_ERROR_CODE;
    	String errorMsg = PARAM_ERROR_MSG;
    	try{
    		Map<String, Object> dataMap = new HashMap<String,Object>();
    		
    		//根据条件查找相应 的商品信息 
    		ProductExample example = new ProductExample();
    		//example.setOrderByClause("CREATE_TIME DESC");
    		// 封装分页参数
            example = this.handlePageQuery(request, example);
    		
    		Criteria criteria = example.createCriteria();
    		criteria.andIsEffectiveEqualTo(DBConst.TRUE);
    		
    		if( StringHelper.isNotBlank(categoryId) && !"0".equals(categoryId) ){
    			criteria.andCategoryIdEqualTo(categoryId);
    		}
    		
    		if( StringHelper.isNotBlank(orderType) ){
    			if( "priceDesc".equals(orderType) ){
    				example.setOrderByClause("PRODUCT_ORGIN_PRICE DESC");
    			}
    			if( "priceAsc".equals(orderType) ){
    				example.setOrderByClause("PRODUCT_ORGIN_PRICE ASC");
    			}
    			if( "salesDesc".equals(orderType) ){
    				example.setOrderByClause("TOTAL_SALES DESC");
    			}
    			if( "commissionAsc".equals(orderType) ){
    				example.setOrderByClause("MARKET_PROFIT DESC");
    			}
    			if( "commissionDesc".equals(orderType) ){
    				example.setOrderByClause("MARKET_PROFIT ASC");
    			}
    		}else{
    			//默认使用商品的创建时间倒序
    			example.setOrderByClause("UPDATE_TIME DESC");
    			example.setOrderByClause("REORDER ASC");
    		}
    		
    		if( StringHelper.isNotBlank(percentFeedback) ){
    			example.setOrderByClause("PERCENT_FEEDBACK DESC");
    		}
    		
    		//根据商品的名字模糊查询
    		if(StringHelper.isNotBlank(name)){
    			criteria.andNameLike("%"+name+"%");
    		}
    		
        	//过滤价格区间
        	if( StringHelper.isNotBlank(minMaxPrice) ){
        		String[] split = minMaxPrice.split("-");
        		if(split.length==2){
        			String minPrice = split[0];
            		String maxPrice = split[1];
            		if( StringHelper.isNotBlank(minPrice) ){
            			criteria.andProductOrginPriceGreaterThanOrEqualTo(Double.parseDouble(minPrice));
            		}
            		if( StringHelper.isNotBlank(maxPrice) ){
            			criteria.andProductOrginPriceLessThanOrEqualTo(Double.parseDouble(maxPrice));
            		}
        		}
        	}
        	
        	//过滤是否退换货
        	if( StringHelper.isNotBlank( isServenBack) && DBConst.TRUE.equals(isServenBack) ){
        		criteria.andIsServenBackEqualTo(DBConst.TRUE);
        	}
        	
        	//过滤销量区间
        	if( StringHelper.isNotBlank(minMaxSales) ){
        		String[] split = minMaxSales.split("-");
        		if( split.length == 2 ){
        			String minSale = split[0];
            		String maxSale = split[1];
            		if( StringHelper.isNotBlank(minSale) ){
            			criteria.andTotalSalesGreaterThanOrEqualTo(Integer.parseInt(minSale));
            		}
            		if( StringHelper.isNotBlank(maxSale) ){
            			criteria.andTotalSalesLessThanOrEqualTo(Integer.parseInt(maxSale));
            		}
            		
        		}
        		
        	}
        	int count = productService.count(example);
        	List<Product> products = productService.list(example);
        	dataMap.put("products", products);
        	dataMap.put("productCount", count + "");
         
        	resultMap.put(DATA, dataMap);
			result = SUCCESS;
			errorCode = SUCCESS_ERROR_CODE;
        	errorMsg = SUCCESS_ERROR_MSG;  	
        	
    	}catch(Exception e){
    		errorCode = SERVER_ERROR_CODE;
        	errorMsg = SERVER_ERROR_MSG;
        	//log(e);
        	logException("MallProductInterface", "index", e.toString(),"折扣商城中心商品列表",e);
    		
    	}
    	resultMap.put(RESULT, result);
    	resultMap.put(ERROR_CODE, errorCode);
    	resultMap.put(ERROR_MSG, errorMsg);
    	isCrrossDomain(response);
    	return resultMap;
    }
    
    

    /**
     * APP商品详情信息
     * @param categoryId 类别ID
     * @param orderType 排序类型
     * @param minMaxPrice 最小到最大的价格区间，中间用-号相隔
     * @param minMaxPrice 最小到最大的销量区间     中间用-号相隔
     * @return
     */
    @RequestMapping(value="/detail")
    @ResponseBody
    public Map<String,Object> detail(HttpServletRequest request,HttpServletResponse response,String productId,String type){
    	Map<String, Object> resultMap = new HashMap<String,Object>();
    	String result = FAIL;
    	String errorCode = PARAM_ERROR_CODE;
    	String errorMsg = PARAM_ERROR_MSG;
    	try{
    		//判断必要的参数
    		if( StringHelper.isNotBlank(productId) ){
    			Map<String, Object> dataMap = new HashMap<String,Object>();
        		
        		//根据ID查找商品详情以及还有商品的SKU信息
        		Product product = productService.get(productId);
        		if( null != product ){
        			product.setProductHongbao(getHongbao(product));
            		product.setProductPrice(getProdcutPrice(product));
            		if( StringHelper.isNotBlank(type) ){
            			product = filterSeckillPriceDetail(product);
            		}
            		dataMap.put("product", product);
                	
            		//根据商品信息查找 商品的SKU信息
            		ProductSkuExample example = new ProductSkuExample();
            		example.setOrderByClause("IS_MAIN DESC");
            		com.itic.mall.system.productsku.persistence.model.ProductSkuExample.Criteria criteria = example.createCriteria();
            		criteria.andProductIdEqualTo(productId);
            		List<ProductSku> skus = productSkuService.list(example);
            		if(skus.size()>0){
            			for(ProductSku tmp:skus){
            				if(StringHelper.isNotBlank(tmp.getProductPropertys())){
            					String propertysTmp="";
            					//如果商品有属性的话
            					String[] split = tmp.getProductPropertys().split(",");
            					
            					for(int i=0;i<split.length;i++){
            						String de = split[i];
            						String[] split2 = de.split(":");
            						if(split2.length>0){
            							propertysTmp += getPropertyName(split2[0])+":" ;
                					    if( i==split.length-1 ){
                					    	propertysTmp += getPropertyValueName(split2[1]) ;
                					    }else{
                					    	propertysTmp += getPropertyValueName(split2[1])+"," ;
                					    }
            						}
            					    
            					}
            					tmp.setProductPropertys(propertysTmp);
            					if( StringHelper.isNotBlank(type) ){
            						filterSkuSeckillPriceDetail(tmp);
            					}
            				}
            			}
            		}
            		dataMap.put("skus", skus);
            		dataMap.put("isSeckill", isfilterSeckillPriceDetailNew(product));
                	resultMap.put(DATA, dataMap);
        			result = SUCCESS;
        			errorCode = SUCCESS_ERROR_CODE;
                	errorMsg = SUCCESS_ERROR_MSG;  	
        		}else{
        			errorCode = PRODUCT_NULL_ERROR_CODE;
                	errorMsg = PRODUCT_NULL_ERROR_MSG;  	
        		}
        		
    		}
        	
    	}catch(Exception e){
    		errorCode = SERVER_ERROR_CODE;
        	errorMsg = SERVER_ERROR_MSG;
        	//log(e);
        	logException("MallProductInterface", "detail", e.toString(),"折扣商城中心商品详情",e);
    	}
    	resultMap.put(RESULT, result);
    	resultMap.put(ERROR_CODE, errorCode);
    	resultMap.put(ERROR_MSG, errorMsg);
    	isCrrossDomain(response);
    	return resultMap;
    }
    
    /**
     * APP折扣商城中心
     * @param categoryId 类别ID
     * @param orderType 排序类型
     * @param minMaxPrice 最小到最大的价格区间，中间用-号相隔
     * @param minMaxPrice 最小到最大的销量区间     中间用-号相隔
     * @return
     */
    @RequestMapping(value="/categorys")
    @ResponseBody
    public Map<String,Object> categorys(HttpServletRequest request,HttpServletResponse response){
    	Map<String, Object> resultMap = new HashMap<String,Object>();
    	String result = FAIL;
    	String errorCode = PARAM_ERROR_CODE;
    	String errorMsg = PARAM_ERROR_MSG;
    	try{
        	//查找相应的分类信息
        	CategoryExample categoryExample = new CategoryExample();
        	categoryExample.createCriteria().andIsEffectiveEqualTo(DBConst.TRUE);
        	List<Category> categorys = categoryService.list(categoryExample);
        	resultMap.put(DATA, categorys);
			result = SUCCESS;
			errorCode = SUCCESS_ERROR_CODE;
        	errorMsg = SUCCESS_ERROR_MSG;  	
        	
    	}catch(Exception e){
    		errorCode = SERVER_ERROR_CODE;
        	errorMsg = SERVER_ERROR_MSG;
        	logException("MallIndexInterface", "categorys", e.toString(),"获得商城所有商品类别信息",e);
    	}
    	resultMap.put(RESULT, result);
    	resultMap.put(ERROR_CODE, errorCode);
    	resultMap.put(ERROR_MSG, errorMsg);
    	isCrrossDomain(response);
    	return resultMap;
    }
    
    /**
     * APP商品分享
     * @param categoryId 类别ID
     * @param orderType 排序类型
     * @param minMaxPrice 最小到最大的价格区间，中间用-号相隔
     * @param minMaxPrice 最小到最大的销量区间     中间用-号相隔
     * @return
     */
    @RequestMapping(value="/share")
    @ResponseBody
    public Map<String,Object> share(HttpServletRequest request,HttpServletResponse response,String productId,String token ){
    	Map<String, Object> resultMap = new HashMap<String,Object>();
    	String result = FAIL;
    	String errorCode = PARAM_ERROR_CODE;
    	String errorMsg = PARAM_ERROR_MSG;
    	try{
    		//判断必要的参数 
    		if( StringHelper.isNotBlank(productId) ){
    			Product product = productService.get(productId);
    			if( null != product ){
    				Map<String, Object> dataMap = new HashMap<String,Object>();
        			
        			dataMap.put("imgUrl", product.getMainImageUrl());
    				String title = sysSettingService.getByKey("SHARE_TITLE");
    				String url = sysSettingService.getByKey("MALL_SHARE_PRODUCT");
    				//is yun zhu
    				url=url+productId;
    				if( StringHelper.isNotBlank(token) ){
    					MallUser user = getMallUserByToken(token);
    					if( null != user ){
    						MarketUser muser = getMarketUserByMallUser(user);
    						if( null != muser ){
    							url = url + "&yunId=" + muser.getId();
    						}
    						//url =url + "&yunId=" + muser.getId();
    					}
    				}
    				dataMap.put("title", title==null?"友惠家商城":title);
    				dataMap.put("content", product.getName() );
    				dataMap.put("url", url );
                	resultMap.put(DATA, dataMap);
        			result = SUCCESS;
        			errorCode = SUCCESS_ERROR_CODE;
                	errorMsg = SUCCESS_ERROR_MSG;  	
    			}else{
        			errorCode = ORDER_NULL_ERROR_CODE;
                	errorMsg = ORDER_NULL_ERROR_MSG;  
    			}
    		}
        	
    	}catch(Exception e){
    		errorCode = SERVER_ERROR_CODE;
        	errorMsg = SERVER_ERROR_MSG;
        	//log(e);
        	logException("MallProductInterface", "detail", e.toString(),"折扣商城中心商品详情",e);
    	}
    	resultMap.put(RESULT, result);
    	resultMap.put(ERROR_CODE, errorCode);
    	resultMap.put(ERROR_MSG, errorMsg);
    	isCrrossDomain(response);
    	return resultMap;
    } 
    
    
    
    
    /**
     * APP商品详情中所有的评价信息
     * @param categoryId 类别ID
     * @param isHaveImg 只有传1时才会返回所有带图的评价
     * @return
     */
    @RequestMapping(value="/feedbacks")
    @ResponseBody
    public Map<String,Object> feedbacks( HttpServletRequest request,HttpServletResponse response,String productId,String isHaveImg ){
    	Map<String, Object> resultMap = new HashMap<String,Object>();
    	String result = FAIL;
    	String errorCode = PARAM_ERROR_CODE;
    	String errorMsg = PARAM_ERROR_MSG;
    	try{
    		//判断必要的参数
    		if( StringHelper.isNotBlank(productId) ){
    			Map<String, Object> dataMap = new HashMap<String,Object>();
        		ProductFeedbackExample example = new ProductFeedbackExample();
        		example.setOrderByClause("CREATE_TIME DESC");
        		com.itic.mall.system.productfeedback.persistence.model.ProductFeedbackExample.Criteria criteria = example.createCriteria().andIsEffectiveEqualTo(DBConst.TRUE);
        		criteria.andProductIdEqualTo(productId);
        		if( StringHelper.isNotBlank(isHaveImg) && "1".equals(isHaveImg) ){
        			criteria.andImageUrlsIsNotNull();
        		}
        		List<ProductFeedback> list = productFeedbackService.list(example);
        		
        		if( list.size() > 0 ){
        			for( ProductFeedback tmp : list ){
        				MallUser user = mallUserService.get(tmp.getUserId());
        				if( null != user ){
        					tmp.setUserId(user.getUserNickName());
        				}else{
        					tmp.setUserId("匿名");
        				}
        				String string = tmp.getNote();
        				String note = "";
        				if( StringHelper.isNotBlank(string) ){
        					String[] split = string.split(",");
        					for( int i=0; i<split.length; i++ ){
        						String[] split2 = split[i].split(":");
        						if( split2.length>1 ){
        							ProductProperty productProperty = productPropertyService.get(split2[0]);
        							note+=productProperty.getName()+":";
        							ProductPropertyValue productPropertyValue = productPropertyValueService.get(split2[1]);
        							note+=productPropertyValue.getPropertyValue()+";";
        						}
        					}
        					tmp.setNote(note);
        				}
        			}
        		}
        		dataMap.put("feedbacks", list);
        		dataMap.put("totalFeedbacks", getTotalFeedbacks(productId));//总评论数量
        		dataMap.put("totalImageFeedbacks", getTotalImageFeedbacks(productId));//有图片的评论数量
            	resultMap.put(DATA, dataMap);
    			result = SUCCESS;
    			errorCode = SUCCESS_ERROR_CODE;
            	errorMsg = SUCCESS_ERROR_MSG;  	
    		}
        	
    	}catch(Exception e){
    		errorCode = SERVER_ERROR_CODE;
        	errorMsg = SERVER_ERROR_MSG;
        	//log(e);
        	logException("MallProductInterface", "feedbacks", e.toString(),"折扣商城中心商品评价信息列表",e);
    	}
    	resultMap.put(RESULT, result);
    	resultMap.put(ERROR_CODE, errorCode);
    	resultMap.put(ERROR_MSG, errorMsg);
    	isCrrossDomain(response);
    	return resultMap;
    }
    
    public String getTotalFeedbacks( String productId ){
    	ProductFeedbackExample example = new ProductFeedbackExample();
    	com.itic.mall.system.productfeedback.persistence.model.ProductFeedbackExample.Criteria criteria = example.createCriteria().andIsEffectiveEqualTo(DBConst.TRUE);
		criteria.andProductIdEqualTo(productId);
		//criteria.andImageUrlsIsNotNull();
		Integer count = productFeedbackService.count(example);
		return count+"";
    }
    
    public String getTotalImageFeedbacks( String productId ){
    	ProductFeedbackExample example = new ProductFeedbackExample();
    	com.itic.mall.system.productfeedback.persistence.model.ProductFeedbackExample.Criteria criteria = example.createCriteria().andIsEffectiveEqualTo(DBConst.TRUE);
		criteria.andProductIdEqualTo(productId);
		criteria.andImageUrlsIsNotNull();
		Integer count = productFeedbackService.count(example);
		return count+"";
    }

    public String getPropertyName(String id){
    	ProductProperty property = productPropertyService.get(id);
    	return property.getName();
    }
    
    public String getPropertyValueName(String id){
    	ProductPropertyValue propertyValue = productPropertyValueService.get(id);
    	return propertyValue.getPropertyValue();
    }
    
    public List<Banner> getBanners(){
    	BannerExample example = new BannerExample();
    	example.setOrderByClause("REORDER ASC");
    	com.itic.mall.system.banner.persistence.model.BannerExample.Criteria criteria = example.createCriteria();
    	criteria.andIsEffectiveEqualTo(DBConst.TRUE);
    	criteria.andTypeEqualTo("002");
    	List<Banner> list = bannerService.list(example);
    	return list;
    }
    
    public List<Product> getBaokuans(){
    	ProductExample example = new ProductExample();
    	example.setOrderByClause("BAOKUAN_ORDER ASC");
    	Criteria criteria = example.createCriteria();
    	criteria.andIsEffectiveEqualTo(DBConst.TRUE);
    	criteria.andIsBaokuanEqualTo("001");
    	List<Product> list = productService.list(example);
    	return list;
    }
    
}